<template>
	<!-- 套餐列表 -->
	<view class="hot-goods u-m-b-10 u-p-x-16">
		<view class="big-card-wrap u-p-10">
			<block v-for="item in goodsList" :key="item.id">

				<view class="big-goods u-flex u-p-20 u-col-top u-m-b-16">
					<u-image ref="uImage" :width="220" :height="220" border-radius="10" :src="item.image" mode="aspectFill"></u-image>
					<view class=" card-right u-m-l-20 u-flex-col u-row-between">
						<view class="">
							<view class="goods-title u-ellipsis-1 u-m-t-10 u-m-b-10">
								<u-tag
									class="title-tag u-m-r-10"
									:text="tag.text"
									size="mini"
									:bg-color="tag.tagBg"
									:border-color="tag.tagBg"
									color="#fff"
								/>
								{{ item.title }}
							</view>
							<view class="subtitle-text u-m-b-10 u-ellipsis-1">{{ item.title }}</view>
						</view>
						<view class=" u-flex u-row-between u-col-center">
							<view class="font-OPPOSANS">
								<view class="price">{{ item.price }}</view>
								<view class="origin-price">{{ item.originPrice }}</view>
							</view>
				
							<!-- 加入购物车 -->
							<view class="cart-box">
				                <button class="u-reset-button item-btn buy-btn" @click="gotoComboDetail(item.id)">去购买</button>
							</view>
						</view>
					</view>
				</view>

			</block>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			tag: {
				text: '套餐',
				tagBg: '#FF5854',
				goodsBg: '/imgs/tag/seckill_x_bg.png',
				btnText: '去购买',
				btnBg: 'background: linear-gradient(90deg, #D01325, #ED3C30);'
			},
			listParams: {
				page: 1
			}, //当前分页
			lastPage: 1, //总分页
			total: 0, //总商品数
			perPage: 0, //单页商品数
			goodsList: []
		};
	},
	onLoad() {
		this.getGoodsList()
	},
	methods: {
		// 商品列表
		getGoodsList() {
			let that = this;
			that.$http('goods.combolist', this.listParams).then(res => {				
				if (res.code === 1) {
					this.lastPage = res.data.last_page;
					this.total = res.data.total;
					this.perPage = res.data.per_page;
					that.goodsList = [...that.goodsList, ...res.data.data];
				}
			});
		},
		
		gotoComboDetail(id) {
			this.$Router.push({ path: '/pages/goods/combo/detail', query: { id: id } })
		},

		// 加载更多
		loadMore() {
			if (this.listParams.page < this.lastPage) {
				this.isRefresh = true;
				this.listParams.page += 1;
				this.getGoodsList();
			}
		}
	}
};
</script>

<style lang="scss">
// 为你推荐
.hot-goods {
	background: none;
	.refresh-btn {
		margin-left: 50%;
		transform: translateX(-50%);
		width: 156rpx;
		line-height: 50rpx;
		background: #ffffff;
		border-radius: 25rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #999999;
		white-space: nowrap;
	}
	.refresh-active {
		transform: rotate(360deg);
		transition: all linear 0.5s;
	}
}

// 大商品卡片
.big-goods {
	width: 710rpx;
	height: 260rpx;
	background: #ffffff;
	border-radius: 20rpx;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	.card-right {
		width: 430rpx;
		height: 220rpx;
	}
	.goods-title {
		font-size: 30rpx;
		font-weight: 600;
		width: 400rpx;
		color: #000000;
		padding-top: 6rpx;

		.title-tag {
			transform: scale(0.9);
			position: relative;
			top: -6rpx;
		}
	}
	.subtitle-text {
		font-size: 22rpx;
		width: 400rpx;
		font-weight: 500;
		color: #666666;
	}
	.tag-box {
		border: 1rpx solid #ff0000;
		display: inline-block;
		font-size: 20rpx;
		line-height: 30rpx;
		padding: 0 10rpx;
		color: #ff0000;
		border-radius: 8rpx;
	}

	// 购物车
	.cart-box {
		.cart-btn {
			width: 54rpx;
			height: 54rpx;
			border-radius: 50%;
			padding: 0;
			background: linear-gradient(90deg, #dd0000, #ff0000);
		}
		.buy-btn {
			width: 120rpx;
			line-height: 50rpx;
			background: linear-gradient(90deg, #dd0000, #ff0000);
			border-radius: 25rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #ffffff;
		}
	}

	// 价格
	.price {
		color: #ff0000;
		font-weight: 600;
		&::before {
			content: '￥';
			font-size: 20rpx;
		}
	}
	.origin-price {
		color: #c4c4c4;
		font-size: 24rpx;
		text-decoration: line-through;
		&::before {
			content: '￥';
			font-size: 20rpx;
		}
	}
}
</style>
